<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: libowu
  Date: 18-10-20
  Time: 下午8:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">

    <style type="text/css">
        body{
            background: rgba(0,60,20,0);
        }
        .fu-parent{
            position: absolute;
            width: 1200px;
            height: 100%;
            left: 50%;
            margin-left: -600px;
            background: rgba(0,0,0,0.3);
            overflow: hidden;
        }
        .fu-detailHead{
            height: 100%;
            width: 400px;
            float: left;
            overflow: hidden;
        }
        img{
            width: 100%;
            height: 100%;
            display: block;
            overflow: hidden;
        }

        .fu-content{
            height: 100%;
            width: 800px;
            margin: 0;
            float: right;
        }

        .fu-content span label{
            font-weight: 700;
        }
        .fu-option{
            text-align: center;
            align-content: center;
            margin-top: 160px;
        }
        .fu-option button{
            margin-left: 10px;
        }

        .fu-edit{
            width: 100%;
            height: 900px;
        }


        .input-group{
            width: 100%;
            height: 40px;
            margin-bottom: 40px;
        }
        .input-group:first-child{
            margin-top: 120px;
        }
        .input-group span{
            height: 100%;
        }
        .input-group input{
            height: 100%;
        }

        .fu-edit .fu-content{
            text-align: center;
            align-content: center;
            padding-left: 15%;
            padding-right: 15%;
        }


        .fu-choose{
            text-align: left;
            align-content: start;
            font-size: 18px;
            color: white;
            margin-bottom: 20px;
            display: flex;
        }

        .fu-choose label{
            margin-right: 20px;
        }

        .fu-choose .fu-chooseTy{
            flex: 1;
            text-align: right;
            align-content: end;
        }

        .fu-choose .fu-chooseSe{
            flex: 1;
            text-align: left;
            align-content: start;
        }


        .fu-al{
            height: 60px;
            width: 200px;
            position: absolute;
            top: 20px;
            left: 46%;
            border-radius: 10px;
            color: white;
            text-align: center;
            align-content: center;
            font-size: 16px;
            line-height: 60px;
            display: none;
        }
    </style>

</head>
<body>

<div class="fu-parent">

    <form method="post" name="form" action="/futer/addUserSubmit">
        <div class="fu-box fu-edit">
            <div class="fu-detailHead">
                <img src="/img/appLogo/ysn.jpeg"/>
            </div>

            <div class="fu-content">
                <div class="input-group">
                    <span class="input-group-addon" id="basic-addon1">姓名</span>
                    <input type="text" class="form-control" aria-describedby="basic-addon1" required="required" name="name">
                </div>

                <c:if test="${sessionScope.type=='admin'}">
                    <div class="input-group">
                        <span class="input-group-addon" id="basic-addon8">密码</span>
                        <input type="text" class="form-control" aria-describedby="basic-addon1"  required="required" name="password">
                    </div>
                </c:if>


                <div class="input-group">
                    <span class="input-group-addon" id="basic-addon9">年龄</span>
                    <input type="number" class="form-control"  aria-describedby="basic-addon1"  min="0" max="200" name="age">
                </div>

                <div class="input-group">
                    <span class="input-group-addon" id="basic-addon3">地址</span>
                    <input type="text" class="form-control"  aria-describedby="basic-addon1" name="address">
                </div>

                <div class="input-group">
                    <span class="input-group-addon" id="basic-addon4">学历</span>
                    <input type="text" class="form-control" aria-describedby="basic-addon1"  name="education">
                </div>

                <div class="input-group">
                    <span class="input-group-addon" id="basic-addon5">邮件</span>
                    <input type="text" class="form-control" aria-describedby="basic-addon1"  name="email">
                </div>


                <div class="fu-choose">

                    <div class="fu-chooseSe">
                        <span>性别：</span><label><input type="radio" name="sex" checked value="男"/>男</label>
                        <label><input type="radio" name="sex" value="女"/>女</label>
                    </div>


                    <c:if test="${sessionScope.user.type=='admin'}">
                        <div class="fu-chooseTy">
                            <span>类型：</span><label><input type="radio" name="type" checked value="admin"/>admin</label>
                            <label style="margin-right: 20px"><input type="radio" name="type" checked value="user"/>user</label>
                        </div>
                    </c:if>

                    <c:if test="${sessionScope.user.type!='admin'}">
                        <div class="fu-chooseTy">
                            <span>类型：</span><label style="margin-right: 20px"><input type="radio" name="type" checked value="user"/>user</label>
                        </div>
                    </c:if>

                </div>



                <div class=" fu-option " >
                    <a href="/futer/userAdmin" class="btn btn-info">返回</a>
                    <button type="submit" class="btn btn-info" >保存</button>
                </div>
            </div>

        </div>
    </form>

    <div class="fu-al" id="al">
        保存成功
    </div>
</div>


<script type="text/javascript">


    if ('${result}'!=null || '${result}'!=''){
        if ('${result}'=='1'){
            setTimeout(hide,2000);
            (document.getElementById("al")).style.zIndex='999';
            (document.getElementById("al")).style.display='block';
            (document.getElementById("al")).style.backgroundColor='green';
            (document.getElementById("al")).innerText='添加成功';
        } else if ('${result}'=='-10') {
            setTimeout(hide,2000);
            (document.getElementById("al")).style.zIndex='999';
            (document.getElementById("al")).style.display='block';
            (document.getElementById("al")).style.backgroundColor='red';
            (document.getElementById("al")).innerText='添加失败，用户已存在';
        }else if ('${result}'=='-5'){
            setTimeout(hide,2000);
            (document.getElementById("al")).style.zIndex='999';
            (document.getElementById("al")).style.display='block';
            (document.getElementById("al")).style.backgroundColor='red';
            (document.getElementById("al")).innerText='邮箱已被被使用，请更换邮箱';
        }
    }

    function hide(){
        (document.getElementById("al")).style.display='none';
    }

    if ('${login}'=='login'){
        parent.sengToLogin();
    }
</script>
</body>
</html>
